import 'dart:io';

import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';
import 'package:images_picker/images_picker.dart';
import 'package:meal/constant/antd_icons.dart';
import 'package:meal/constant/sizes.dart';
import 'package:meal/route/route.dart';
import 'package:meal/utils/colors.dart';
import 'package:meal/utils/styles.dart';
import 'package:meal/utils/tools.dart';

///
/// 创建团购
///
class GroupAdd extends StatefulWidget {
  const GroupAdd({Key? key}) : super(key: key);

  @override
  State<GroupAdd> createState() => _GroupAddState();
}

class _GroupAddState extends State<GroupAdd> {
  List<Media> imgs = [];

  List<String> tags = ['免预约', '要预约', '包间可用', '包间除外', '免费WiFi', '免费停车', '推荐自提', '无烟区'];

  List<int> tagIndex = [];

  List<String> invoice = ['提供纸质发票', '提供电子发票'];

  List<int> invoiceIndex = [];

  bool isChecked = true;

  double get leftWidth {
    return Sizes.default90;
  }

  double get rowHeight {
    return Sizes.default60;
  }

  TextSpan get requiredSpan {
    return TextSpan(text: ' *', style: StylesUtils.customTextStyle(color: ColorsUtils.colorFf0));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ToolsUtils.getDefaultBackgroundColor(),
      appBar: ToolsUtils.getDefaultBrnAppBar('创建团购'),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              padding: const EdgeInsets.all(Sizes.default15),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Container(
                    alignment: Alignment.centerLeft,
                    child: Text(
                      '抽成比例：3% 每单',
                      style: StylesUtils.customTextStyle(
                        color: ColorsUtils.color363,
                      ),
                    ),
                  ),
                  Container(
                    alignment: Alignment.centerLeft,
                    margin: const EdgeInsets.only(top: Sizes.default10),
                    child: Text(
                      '团购订单按此比例抽成',
                      style: StylesUtils.customTextStyle(
                          color: ColorsUtils.color999, fontSize: Sizes.default12),
                    ),
                  )
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              padding:
                  const EdgeInsets.symmetric(horizontal: Sizes.default15, vertical: Sizes.default8),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                        width: leftWidth,
                        alignment: Alignment.topLeft,
                        child: Text.rich(TextSpan(
                            text: '商品图片',
                            style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                            children: [requiredSpan])),
                      ),
                      Expanded(
                          child: Container(
                        alignment: Alignment.centerLeft,
                        child: Wrap(
                          spacing: Sizes.default10,
                          runSpacing: Sizes.default10,
                          children: [
                            ...imgs.map((e) => Stack(
                                  children: [
                                    GFImageOverlay(
                                      image: FileImage(File(e.path)),
                                      width: 105,
                                      height: 105,
                                      borderRadius: BorderRadius.circular(Sizes.default5),
                                    ),
                                    Positioned(
                                        top: 10,
                                        right: 10,
                                        child: IconButton(
                                          onPressed: () {
                                            setState(() {
                                              imgs.remove(e);
                                            });
                                          },
                                          icon: Icon(AntdIcons.delete,
                                              size: Sizes.default20,
                                              color: ColorsUtils.parseColorFromHexString(
                                                  ColorsUtils.colorFf0)),
                                        ))
                                  ],
                                )),
                            InkWell(
                              onTap: () {
                                ToolsUtils.openCupertinoModalPopup(
                                    context, setMediaImg, setMediaImg);
                              },
                              child: Container(
                                width: 105,
                                height: 105,
                                decoration: BoxDecoration(
                                    color: ColorsUtils.rgba(247, 247, 247, 1),
                                    borderRadius: BorderRadius.circular(Sizes.default5)),
                                alignment: Alignment.center,
                                child: ToolsUtils.getUrlSvg(
                                    'https://cdn7.axureshop.com/demo/1525603/images/发布商品_单品/u1046.svg',
                                    width: 24,
                                    height: 20),
                              ),
                            )
                          ],
                        ),
                      ))
                    ],
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                  text: '名称',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default15, color: ColorsUtils.color333),
                                  children: [requiredSpan]),
                            )),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '如烤肉双人套餐',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.text,
                            onChanged: (String content) {},
                          ),
                        ))
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              padding:
                  const EdgeInsets.symmetric(horizontal: Sizes.default15, vertical: Sizes.default8),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(TextSpan(children: [
                              TextSpan(
                                text: '团购价格',
                                style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                              ),
                              requiredSpan
                            ]))),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          margin: const EdgeInsets.only(right: Sizes.default15),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '例如398',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.number,
                            onChanged: (String content) {},
                          ),
                        )),
                        Container(
                          alignment: Alignment.centerRight,
                          child: Text('￥',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color333)),
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                  text: '团购套餐',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default15, color: ColorsUtils.color333),
                                  children: [requiredSpan]),
                            )),
                        Expanded(
                          child: InkWell(
                            child: Container(
                              height: Sizes.default45,
                              padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                              alignment: Alignment.centerLeft,
                              decoration: BoxDecoration(
                                  color: ColorsUtils.rgba(247, 247, 247, 1),
                                  borderRadius:
                                      const BorderRadius.all(Radius.circular(Sizes.default10))),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  Text('添加套餐',
                                      style: StylesUtils.customTextStyle(
                                          fontSize: Sizes.default15, color: ColorsUtils.color797)),
                                  BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 16, 16)
                                ],
                              ),
                            ),
                            onTap: () {
                              Get.toNamed(RouteGet.groupPackage);
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              padding:
                  const EdgeInsets.symmetric(horizontal: Sizes.default15, vertical: Sizes.default8),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(TextSpan(children: [
                              TextSpan(
                                text: '有效期',
                                style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                              ),
                              requiredSpan
                            ]))),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          margin: const EdgeInsets.only(right: Sizes.default15),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '请输入购买后有效期',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.number,
                            onChanged: (String content) {},
                          ),
                        )),
                        Container(
                          alignment: Alignment.centerRight,
                          child: Text('天',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color333)),
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(TextSpan(
                                text: '活动日期',
                                style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                                children: [requiredSpan]))),
                        Expanded(
                          child: InkWell(
                            child: Container(
                              height: Sizes.default45,
                              padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                              alignment: Alignment.centerLeft,
                              decoration: BoxDecoration(
                                  color: ColorsUtils.rgba(247, 247, 247, 1),
                                  borderRadius:
                                      const BorderRadius.all(Radius.circular(Sizes.default10))),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  Text('请选择起止日期',
                                      style: StylesUtils.customTextStyle(
                                          fontSize: Sizes.default15, color: ColorsUtils.color797)),
                                  BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 16, 16)
                                ],
                              ),
                            ),
                            onTap: () {
                              ToolsUtils.openDateRangePicker(context, onConfirm:
                                  (DateTime startDateTime, DateTime endDateTime,
                                      List<int> startSelectedIndex, List<int> endSelectedIndex) {
                                setState(() {});
                              });
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                text: '不可用日期',
                                style: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default15, color: ColorsUtils.color333),
                              ),
                            )),
                        Expanded(
                          child: InkWell(
                            child: Container(
                              height: Sizes.default45,
                              padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                              alignment: Alignment.centerLeft,
                              decoration: BoxDecoration(
                                  color: ColorsUtils.rgba(247, 247, 247, 1),
                                  borderRadius:
                                      const BorderRadius.all(Radius.circular(Sizes.default10))),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  Text('请添加日期',
                                      style: StylesUtils.customTextStyle(
                                          fontSize: Sizes.default15, color: ColorsUtils.color797)),
                                  BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 16, 16)
                                ],
                              ),
                            ),
                            onTap: () {
                              ToolsUtils.openDatePicker(context,
                                  onConfirm: (DateTime dateTime, List<int> selectedIndex) {
                                BrnToast.show("onConfirm:  $dateTime   $selectedIndex", context);
                              });
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                  text: '可用时间',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default15, color: ColorsUtils.color333),
                                  children: [requiredSpan]),
                            )),
                        Expanded(
                          child: InkWell(
                            child: Container(
                              height: Sizes.default45,
                              padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                              alignment: Alignment.centerLeft,
                              decoration: BoxDecoration(
                                  color: ColorsUtils.rgba(247, 247, 247, 1),
                                  borderRadius:
                                      const BorderRadius.all(Radius.circular(Sizes.default10))),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  Text('请添加日期',
                                      style: StylesUtils.customTextStyle(
                                          fontSize: Sizes.default15, color: ColorsUtils.color797)),
                                  BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 16, 16)
                                ],
                              ),
                            ),
                            onTap: () {
                              Get.toNamed(RouteGet.groupUseTime);
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(TextSpan(children: [
                              TextSpan(
                                text: '限购数量',
                                style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                              ),
                            ]))),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          margin: const EdgeInsets.only(right: Sizes.default15),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '1-99',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.number,
                            onChanged: (String content) {},
                          ),
                        )),
                        Container(
                          alignment: Alignment.centerRight,
                          child: Text('件/每人每单',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color333)),
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(TextSpan(children: [
                              TextSpan(
                                text: '库存数量',
                                style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                              ),
                              requiredSpan
                            ]))),
                        Expanded(
                            child: Container(
                          height: Sizes.default45,
                          padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                          margin: const EdgeInsets.only(right: Sizes.default15),
                          decoration: BoxDecoration(
                              color: ColorsUtils.rgba(247, 247, 247, 1),
                              borderRadius:
                                  const BorderRadius.all(Radius.circular(Sizes.default10))),
                          child: TextField(
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color363, fontSize: Sizes.default15),
                            decoration: InputDecoration(
                                border: const OutlineInputBorder(
                                  borderSide: BorderSide.none,
                                ),
                                isCollapsed: true,
                                filled: true,
                                fillColor: Colors.transparent,
                                contentPadding: const EdgeInsets.symmetric(
                                    horizontal: Sizes.default10, vertical: Sizes.default10),
                                constraints: const BoxConstraints(minHeight: Sizes.default45),
                                hintText: '1-999',
                                hintStyle: StylesUtils.customTextStyle(
                                    fontSize: Sizes.default14, color: ColorsUtils.color999)),
                            keyboardType: TextInputType.number,
                            onChanged: (String content) {},
                          ),
                        )),
                        Container(
                          alignment: Alignment.centerRight,
                          child: Text('份',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color333)),
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: rowHeight,
                    alignment: Alignment.centerLeft,
                    child: Row(
                      children: [
                        Container(
                            width: leftWidth,
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                  text: '使用规则',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: Sizes.default15, color: ColorsUtils.color333),
                                  children: [requiredSpan]),
                            )),
                        Expanded(
                          child: InkWell(
                            child: Container(
                              height: Sizes.default45,
                              padding: const EdgeInsets.symmetric(horizontal: Sizes.default10),
                              alignment: Alignment.centerLeft,
                              decoration: BoxDecoration(
                                  color: ColorsUtils.rgba(247, 247, 247, 1),
                                  borderRadius:
                                      const BorderRadius.all(Radius.circular(Sizes.default10))),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  Text('请添加规则',
                                      style: StylesUtils.customTextStyle(
                                          fontSize: Sizes.default15, color: ColorsUtils.color797)),
                                  BrunoTools.getAssetSizeImage(BrnAsset.iconRightArrow, 16, 16)
                                ],
                              ),
                            ),
                            onTap: () {
                              Get.toNamed(RouteGet.groupUseRule);
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              padding:
                  const EdgeInsets.symmetric(horizontal: Sizes.default15, vertical: Sizes.default8),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Container(
                    alignment: Alignment.centerLeft,
                    padding: const EdgeInsets.only(bottom: Sizes.default20),
                    child: Text(
                      '商家服务',
                      style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                    ),
                  ),
                  GridView(
                    physics: const NeverScrollableScrollPhysics(),
                    gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 2,
                        mainAxisSpacing: Sizes.default20,
                        crossAxisSpacing: Sizes.default10,
                        childAspectRatio: 5.0 //宽高比为2
                        ),
                    shrinkWrap: true,
                    children: tags
                        .asMap()
                        .map((index, value) => MapEntry(
                            index,
                            InkWell(
                              child: Container(
                                alignment: Alignment.center,
                                height: Sizes.default35,
                                decoration: changeBoxDecoration(tagIndex.contains(index)),
                                child: Text(
                                  value,
                                  style: StylesUtils.customTextStyle(color: ColorsUtils.color797),
                                ),
                              ),
                              onTap: () {
                                setState(() {
                                  if (tagIndex.contains(index)) {
                                    tagIndex.remove(index);
                                    return;
                                  }
                                  if (index > 3) {
                                    tagIndex.add(index);
                                    return;
                                  }
                                  if (index % 2 == 0) {
                                    return adjacentAdd(index);
                                  }
                                  return adjacentReduce(index);
                                });
                              },
                            )))
                        .values
                        .toList(),
                  )
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              padding:
                  const EdgeInsets.symmetric(horizontal: Sizes.default15, vertical: Sizes.default8),
              decoration: const BoxDecoration(color: Colors.white),
              child: ListBody(
                children: [
                  Container(
                    alignment: Alignment.centerLeft,
                    padding: const EdgeInsets.only(bottom: Sizes.default20),
                    child: Text(
                      '发票信息',
                      style: StylesUtils.customTextStyle(color: ColorsUtils.color333),
                    ),
                  ),
                  GridView(
                    physics: const NeverScrollableScrollPhysics(),
                    gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 2,
                        mainAxisSpacing: Sizes.default20,
                        crossAxisSpacing: Sizes.default10,
                        childAspectRatio: 5.0 //宽高比为2
                        ),
                    shrinkWrap: true,
                    children: invoice
                        .asMap()
                        .map((index, value) => MapEntry(
                            index,
                            InkWell(
                              child: Container(
                                alignment: Alignment.center,
                                height: Sizes.default35,
                                decoration: changeBoxDecoration(invoiceIndex.contains(index)),
                                child: Text(
                                  value,
                                  style: StylesUtils.customTextStyle(color: ColorsUtils.color797),
                                ),
                              ),
                              onTap: () {
                                setState(() {
                                  if (invoiceIndex.contains(index)) {
                                    invoiceIndex.remove(index);
                                    return;
                                  }
                                  invoiceIndex.add(index);
                                });
                              },
                            )))
                        .values
                        .toList(),
                  )
                ],
              ),
            ),
          ],
        ),
      ),
      bottomNavigationBar: SafeArea(
        top: false,
        child: Container(
          height: Sizes.default80,
          padding: const EdgeInsets.symmetric(horizontal: Sizes.default20),
          decoration: BoxDecoration(color: ToolsUtils.getDefaultBackgroundColor()),
          child: Column(
            children: [
              Container(
                height: Sizes.default30,
                alignment: Alignment.centerLeft,
                child: Wrap(
                  spacing: Sizes.default5,
                  crossAxisAlignment: WrapCrossAlignment.center,
                  children: [
                    BrnCheckbox(
                      radioIndex: 1,
                      onValueChangedAtIndex: (int index, bool value) {
                        isChecked = value;
                        setState(() {});
                      },
                      isSelected: isChecked,
                      childOnRight: true,
                      mainAxisSize: MainAxisSize.min,
                      child: Text(
                        '阅读并同意',
                        style: StylesUtils.customTextStyle(
                            fontSize: Sizes.default13, color: ColorsUtils.colorE7e),
                      ),
                    ),
                    InkWell(
                      onTap: () {
                        Get.toNamed(RouteGet.groupProtocol);
                      },
                      child: Text('《团购服务协议》',
                          style: StylesUtils.customTextStyle(
                              color: ColorsUtils.colorFf6, fontSize: Sizes.default13)),
                    ),
                  ],
                ),
              ),
              Expanded(
                  child: Container(
                alignment: Alignment.center,
                child: FractionallySizedBox(
                  heightFactor: 0.9,
                  widthFactor: 0.9,
                  child: GFButton(
                      onPressed: () {},
                      text: '创建',
                      textStyle: StylesUtils.customTextStyle(fontSize: Sizes.default16),
                      shape: GFButtonShape.pills,
                      type: GFButtonType.solid,
                      size: GFSize.LARGE,
                      color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorFf6)),
                ),
              ))
            ],
          ),
        ),
      ),
    );
  }

  void adjacentAdd(int index) {
    tagIndex.add(index);
    tagIndex.remove(index + 1);
  }

  void adjacentReduce(int index) {
    tagIndex.add(index);
    tagIndex.remove(index - 1);
  }

  BoxDecoration changeBoxDecoration(bool isActive) {
    if (isActive) {
      return BoxDecoration(
          color: ColorsUtils.rgba(255, 238, 238, 1),
          borderRadius: BorderRadius.circular(Sizes.default15),
          border: Border.all(color: ColorsUtils.rgba(255, 110, 83, 1)));
    }
    return BoxDecoration(
      color: ColorsUtils.rgba(245, 245, 245, 1),
      borderRadius: BorderRadius.circular(Sizes.default15),
    );
  }

  void setMediaImg(List<Media> res) {
    setState(() {
      imgs.addAll(res);
    });
  }
}
